//app.js
App({
  onLaunch: function () {
    // wx.loadFontFace({
    //   family: 'webfont',
    //   source: 'url("http://127.0.0.1:8087/webfont1.ttf")',
    //   success: function (res) {
    //     console.log(res.status) //  loaded
    //   },
    //   fail: function (res) {
    //     console.log(res.status) //  error
    //   },
    //   complete: function (res) {
    //     console.log(res.status);
    //   }
    // });
  },
  checkUserInfo:function(cb){
    let that = this
    if (that.globalData.userInfo)
    {
      typeof cb == "function" && cb(that.globalData.userInfo, true);
    }
    wx.getSetting({
      success: function (res) {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称
          wx.getUserInfo({
            success: function (res) {
              that.globalData.userInfo = JSON.parse(res.rawData);
              typeof cb == "function" && cb(that.globalData.userInfo, true);
            }
          })
        }
        else
        {
          typeof cb == "function" && cb(that.globalData.userInfo, false);
        }
      }
    })
  },
  globalData: {
    userInfo: null,
    kinds: [{
      icon: 'icon-viewlist',
      name: '碎碎念',
      catid: '11'
    }, {
        icon: 'icon-viewgallery',
      name: '还没有',
      catid: '12'
    },
    {
      icon: 'icon-kafei',
      name: '想好',
      catid: '13'
    }],
    //默认图片
    defaultImageUrl: 'https://fublog.oss-cn-shenzhen.aliyuncs.com/default.jpg',
    imageUrl: 'http://image.bug2048.com/',
    imageStyle200To200: 'imageView2/1/w/200/h/200/q/100',
    imageStyle600To300: 'imageView2/1/w/600/h/300/q/75|watermark/2/text/QnVn55Sf5rS7MjA0OA==/font/5a6L5L2T/fontsize/280/fill/IzAwMDAwMA==/dissolve/100/gravity/SouthEast/dx/10/dy/10'
  }, compareVersion:function(v1, v2) {
    v1 = v1.split('.')
  v2 = v2.split('.')
  const len = Math.max(v1.length, v2.length)

  while(v1.length <len) {
      v1.push('0')
    }
  while(v2.length <len) {
      v2.push('0')
    }

  for(let i = 0; i<len; i++) {
  const num1 = parseInt(v1[i])
  const num2 = parseInt(v2[i])

  if (num1 > num2) {
    return 1
  } else if (num1 < num2) {
    return -1
  }
}

return 0
}
})